package org.seaurchin.web;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.*;

import org.seaurchin.category.CategoryTree;
import org.seaurchin.database.persist;
import org.seaurchin.search.SearchFiles;

public class SearchServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String category = request.getParameter("selectedCategory");
		String searchString = request.getParameter("searchString");
		
		try {
			Iterator results = new SearchFiles().runCategoryBasedSearch(searchString, category);
			request.setAttribute("results", results);
		} catch(Exception e) {
			
		}
		
		RequestDispatcher view = request.getRequestDispatcher("displayResults.jsp");
		
		view.forward(request, response);		
	}
}
